#ifndef HH_CAM_CONTROL_INTERFACE_H
#define HH_CAM_CONTROL_INTERFACE_H

#include <iostream>
#include <vector>
// #include <opencv2/opencv.hpp>
#include "cam_control_base.hpp"

class cam_control_interface : public cam_control_base
{
    public:
    /**
     * 摄像头数据实体
     * 
     * create by: 陈斌
    */
    struct caminfo
    {
        char * camId;
        char * camIp;
        char * userName;
        char * userPwd;
        int port;
        int streamType;
        int channelId;
        int GUserID=-5;
        int G_nPORT=-1;
        int lRealPlayHandle=-1;
        int callBackNum=-1;
        int camspeed;
        int camType;
        char * camRealIp;
        char * camRealUserName;
        char * camRealPwd;
        int camRealPort;
        // cv::Mat frame;
        char * pBuf;
        char * geoscope;
        char * cmosLen;
        char * minFocal;
        char * northAngle;
        char * camLongitude;
        char * camLatitude;
        char * camHeight;
        char * direction;
        char * tOffset;
        double pan_angle_speed;
        double tilt_angle_speed;
        double zoom_speed;
        // tagcaminfo * nextNode;
    };

    enum MOTION{
        CTL_START=0,
        CTL_STOP=1,
    };

    /// @brief 摄像头控制动作
    /// @author 陈斌
    /// @date 2028-08-29
    enum conntroll_direct{
        UP=0,
        DOWN=1,
        LEFT=2,
        RIGHT=3,
        ZOOMIN=4,
        ZOOMOUT=5,
        STOP=6,
        UPLEFT=7,
        UPRIGHT=8,
        DOWNLEFT=9,
        DOWNRIGHT=10
    };    

    /**
     * 摄像头实体包装
     * 
     * create by: 陈斌
    */
    struct caminfowrap
    {
        std::string  camId;
        std::string camIp;
        std::string userName;
        std::string userPwd;
        int port;
        int streamType;
        int channelId;
        int GUserID=-5;
        int G_nPORT=-1;
        int lRealPlayHandle=-1;
        int callBackNum=-1;
        int camspeed;
        int camType;
        std::string camRealIp;
        std::string camRealUserName;
        std::string camRealPwd;    
        int camRealPort;
        std::string geoscope;
        std::string cmosLen;
        std::string minFocal;
        std::string northAngle;
        std::string camLongitude;
        std::string camLatitude;
        std::string camHeight; 

        std::string direction;
        std::string tOffset;        
    };
    
    template<typename T,typename T2,typename T3>
    struct camptz
    {
        T pan;
        T2 tilt;
        T3 zoom;
    };

    /// @brief 获取最后一个摄像头信息
    /// @return 摄像头信息    
    virtual caminfo getLastCamInfo() = 0;
    
    /// @brief 通过摄像头id查找摄像头信息
    /// @param camId 摄像头id
    /// @return 摄像头信息
    virtual caminfo findCamInfo(const char *camId) = 0;

    /// @brief 获取全局摄像头信息
    /// @return 摄像头信息列表
    virtual std::vector<caminfo> getGlobalCamInfo() =0;
    // void initGlobalCamInfo(caminfo *);

    /// @brief 添加摄像头信息
    /// @param  摄像头信息
    /// @return 成功返回0，失败返回其他
    virtual int addCamInfo(caminfo) =0;

    /// @brief 删除摄像头信息
    /// @param camId 摄像头id
    /// @return 成功返回0，失败返回其他
    virtual int delCamInfo(const char * camId) =0;

    /// @brief 通过端口查找摄像头信息(只适用于海康)
    /// @param  端口
    /// @return 摄像头信息
    virtual caminfo findCamInfoBynPort(int &) =0;

    virtual caminfo camwarp2caminfo(caminfowrap &) =0;
    virtual int add_cam_stream(std::string) =0;
    virtual std::vector<caminfo> get_ptr_from_list(std::vector<std::string> camid_list) =0;

    /// @brief 截取摄像头图片
    /// @param camId 摄像头id
    /// @param filename 保存文件名
    /// @return 成功返回true，失败返回false
    virtual bool CaptrueImgNew(const char* camId,const char * filename) =0;

    /// @brief 控制摄像头
    /// @param camId 摄像头id
    /// @param pan 水平
    /// @param tilt 垂直
    /// @param zoom 缩放
    /// @param action 动作
    virtual void PtzControl(const char *camId,const int &pan,const int &tilt,const int &zoom,const int &action) =0;

    /// @brief 初始化摄像头
    /// @param info 摄像头信息
    /// @return 成功返回0，失败返回其他
    virtual int InitCam(const caminfo info) =0;

    /// @brief 保存摄像头视频
    /// @param camId 摄像头id
    /// @param filename 保存文件名
    /// @return 成功返回true，失败返回false
    virtual bool SaveVideoFile(const char* camId,const char * filename,unsigned long videoTime) =0;
    
    virtual void StartGetStream(caminfo &cam) =0;

    /// @brief 获取摄像头ptz
    /// @param  camId 摄像头id
    /// @return 摄像头ptz
    virtual camptz<int,int,int> get_ptz(const char *camId) =0;

    virtual void Disconnect(caminfo &cam) =0;
    virtual void StartConnect(caminfo &cam) =0;

    /// @brief 手动控制摄像头
    /// @param camId 摄像头id
    /// @param camSpeed 转动速度
    /// @param cmd 转动命令
    /// @param motion 动作
    /// @return 
    virtual int man_control(const char *camId, const int camSpeed, const int cmd, const int motion) =0;

    virtual int set_guserid(const char *camId, const int guserid) =0;

    virtual int set_gnport(const char *camId, const int gnport) =0;

    virtual void set_ptz(const char *,camptz<int,int,int> &&,int action) =0;  

    virtual int set_last_ptz(const char *camId,camptz<int,int,int> &ptz)=0;

    virtual const camptz<int,int,int> *get_last_ptz(const char *camId)=0;
};

#endif // HH_CAM_CONTROL_INTERFACE_H